﻿<Page x:Class="SlotDuino.UI.Pages.OperatorManager"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:dal="clr-namespace:SlotDuino.DAL;assembly=SlotDuino.DAL" 
      xmlns:converter="clr-namespace:SlotDuino.Converter"
      mc:Ignorable="d" 
      Background="{x:Null}"
	  Title="Gerenciamento de Operadores" Loaded="Page_Loaded">

    <Page.Resources>
        <CollectionViewSource x:Key="viewSource" d:DesignSource="{d:DesignInstance dal:Operator, CreateList=True}" />
        <converter:Negate x:Key="Negate" />
    </Page.Resources>
    <Grid>
		<GroupBox Header="Dados do Operador" Width="340" HorizontalAlignment="Right">
            <StackPanel x:Name="formContainer" DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Page, AncestorLevel=1}, Path=CurrentInstance}" IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Page, AncestorLevel=1}, Path=IsEditing}">
				<Label Content="Nome" x:Name="lblName" Margin="5,5,0,5" />
				<TextBox x:Name="txtName" Margin="5,0,0,5" TabIndex="20" Text="{Binding Name, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" />
				<Label Content="E-mail" x:Name="lblEmail" Margin="5,0,0,5" />
                <TextBox x:Name="txtEmail" Margin="5,0,0,5" TabIndex="30" Text="{Binding Email, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" />
				<Label Content="Usuário" x:Name="lblUsername" Margin="5,0,0,5" />
                <TextBox x:Name="txtUsername" Margin="5,0,0,5" TabIndex="40" Text="{Binding Login, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" />
				<Label Content="Senha" x:Name="lblPassword" Margin="5,0,0,5" />
                <PasswordBox x:Name="pwdPassword" Margin="5,0,0,5" TabIndex="50" MaxLength="30" />
				<Label x:Name="lblConfirm" Content="Confirmação da senha" Margin="5,0,0,5" />
                <PasswordBox x:Name="pwdConfirm" Margin="5,0,0,5" TabIndex="60" />
				<Label Content="Aniversário" x:Name="lblBirthday" Margin="5,0,0,5" />
                <DatePicker x:Name="dtpBirthday" Margin="5,0,0,5" Width="110" TabIndex="70" HorizontalAlignment="Left" SelectedDate="{Binding Birthday, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" />
				<Label Content="Telefone" x:Name="lblPhone" Margin="5,0,0,5" />
                <TextBox HorizontalAlignment="Left" x:Name="txtPhone" Width="196" Margin="5,0,0,10" TabIndex="80" Text="{Binding Phone, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" />
                <StackPanel Orientation="Horizontal" Margin="5,0,0,5">
					<CheckBox x:Name="chbIsAdmin" Content="Administrador" Margin="0,8,40,0" TabIndex="90" IsChecked="{Binding IsAdministrator, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" />
                    <Button Content="Salvar" Height="32" x:Name="btnSave" Width="96" TabIndex="100" Click="btnSave_Click" Margin="0,0,10,0" IsDefault="True" />
					<Button Content="Cancelar" Height="32" x:Name="btnCancel" Width="96" TabIndex="100" Click="btnCancel_Click" IsCancel="True" />
				</StackPanel>
            </StackPanel>
		</GroupBox>
		<GroupBox Header="Listagem de Operadores" Margin="0,0,350,0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" d:LayoutOverrides="Width, Height">
			<Grid>
				<StackPanel Orientation="Horizontal" Margin="0,5,0,0" VerticalAlignment="Top">
					<TextBox Height="32" MinWidth="343" Margin="0,0,2,0" FontSize="20" Name="txtSearch" />
					<Button Content="Pesquisar" Height="32" x:Name="btnSearch" Width="80" Margin="2,0" Click="btnSearch_Click" />
					<Button Content="Novo" Height="32" x:Name="btnNew" Width="80" Margin="2,0" Click="btnNew_Click" />
					<Button Content="Editar" Height="32" x:Name="btnEdit" Width="80" Margin="2,0,0,0" Click="btnEdit_Click" />
				</StackPanel>
				<DataGrid DataContext="{StaticResource viewSource}" AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding}" x:Name="dataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" 
					CanUserDeleteRows="False" CanUserAddRows="False" SelectionMode="Single" Background="{StaticResource SelectedBackgroundBrush}" MinHeight="400" Margin="0,42,0,47" d:LayoutOverrides="Width, Height" IsHitTestVisible="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Page, AncestorLevel=1}, Path=IsEditing, Converter={StaticResource Negate}}">
					<DataGrid.Columns>
						<DataGridTextColumn x:Name="idColumn" Binding="{Binding Id}" Header="Id" Width="SizeToHeader" IsReadOnly="True" />
						<DataGridTextColumn x:Name="nameColumn" Binding="{Binding Name}" Header="Nome" IsReadOnly="True" />
						<DataGridTextColumn x:Name="emailColumn" Binding="{Binding Email}" Header="E-mail" IsReadOnly="True" />
						<DataGridTextColumn x:Name="loginColumn" Binding="{Binding Login}" Header="Login" Width="SizeToHeader" IsReadOnly="True" />
						<DataGridCheckBoxColumn x:Name="isAdministratorColumn" Binding="{Binding IsAdministrator}" Header="Administrador" Width="SizeToHeader" IsReadOnly="True" />
					</DataGrid.Columns>
				</DataGrid>
				<Button Content="Excluir" Height="32" x:Name="btnDelete" Width="80" HorizontalAlignment="Right" Margin="0,0,0,5" VerticalAlignment="Bottom" Click="btnDelete_Click" />
            </Grid>
		</GroupBox>
	</Grid>
</Page>
